package demo1;
import java.util.Arrays;
import java.util.Comparator;

public class TestComparable {
    public static void main(String[] args) {

        StudentComparable[] s = new StudentComparable[]{new StudentComparable("zhangsan", 12),
                new StudentComparable("lisi", 10),
                new StudentComparable("wangwu", 8)};

//        Arrays.sort(s);
        mySort(s);
        System.out.println(Arrays.toString(s));
    }

    public static void mySort(Comparable[] comparables) {
        for (int i = 0; i < comparables.length; i++) {
            for (int j = i + 1; j < comparables.length; j++) {
                if (comparables[i].compareTo(comparables[j]) > 0) {
                    Comparable temp = comparables[i];
                    comparables[i] = comparables[j];
                    comparables[j] = temp;
                }
            }
        }
    }
}
